define(["app", "angular", "services/BaseService"], function(app, angular) {
	
	var deps = ["$http", "BaseService"];
	
	function shareResource($http, BaseService) {
        return initResource($http, BaseService.restfulUrl + "share/", BaseService.formHeader);
    }
	
	var postHeader = {
	        "Content-Type" : "application/x-www-form-urlencoded;charset=utf-8"
	};
	
	function initResource($http, preUrl,formHeader) {
        return {
        	save: function (shareVo) {
				return $http.post(preUrl + "saveShare", angular.toJson(shareVo));
			},
			
			edit: function (shareVo) {
				return $http.post(preUrl + "edit", angular.toJson(shareVo));
			},
			deleteShare:function(shareId){
                return $http.post(preUrl+ "deleteShare"+"/"+shareId);
            },
            updateStatus:function(shareId,status){
            	return $http.post(preUrl + "updateStatus", {
                    params: {
                    	shareId: shareId,
                    	status: status
                    }
                });
            },
            shield:function(shareId,optType){
            	return $http.post(preUrl+"shield",{
            		shareId : shareId,
            		optType : optType
                },{
                    headers: postHeader
                });
            },
            
            saveFormShare: function (comData,formData) {
				return $http.post(preUrl + "saveFormShare?"+$.param(comData),formData,  {
					transformRequest: angular.identity,
					headers: {
                        "Content-Type": undefined
                    },
                    transformResponse: function (data) {
                        return {
                            fileId: data
                        };
                    }
				});
			},
			
            queryShareList: function (pageNo,pageSize,content,nickName,shareType,shareStartDate,shareEndDate) {
                return $http.get(preUrl + "queryShareList", {
                    params: {
                        pageSize: pageSize || 10000,
                        pageNo: pageNo || 1,
                        content:content,
                        nickName:nickName,
                        shareType:shareType,
                        shareStartDate:shareStartDate,
                        shareEndDate:shareEndDate
                    }
                });
            },
            shareDetail: function (shareId) {
        		return $http.get(preUrl + "shareDetail"+"/"+shareId);
			}
        };
        
    }
	shareResource.$inject = deps;
	app.lazy.factory("ShareResource", shareResource);
});
